package be.ipl.finito.domaine;

import java.io.Serializable;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

@SuppressWarnings("serial")
@Entity
@Table(name="CASES", schema="FINITO")
public class Case implements Serializable{
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private int id;
	
	@NotNull
	@Min(0)
	@Max(20)
	private int numero;
	
	//ICI demandé OneToOne ou Many
	 @Null
	 @ManyToOne 
	 @JoinColumn(name="JETON_ID") 
	 private Jeton jeton;
	
	 //@ManyToOne
	 //private Plateau plateau;
	 
	 protected Case(){
		 
	 }
	 
	public Case(int numero) {
		this.numero = numero;
	}
	
	public Jeton getJeton() {
		return jeton;
	}
	
	public void setJeton(Jeton jeton) {
		this.jeton = jeton;
	}
	
	public void setNumero(int numero){
		this.numero = numero;
	}
	
	public int getId() {
		return id;
	}
	
	public int getNumero(){
		return numero;
	}
	
	
	
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Case other = (Case) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
